﻿$(document).ready(function () {

    $('.navList li').bind('mouseenter mouseleave', function () {
        $(this).toggleClass('navListHighLight');
    });
    $('.navList li').first().addClass('first');

    $(document).on('click','#btn_selectCategory',function(){
        var catId = $('#categories').val();
        if (catId=="undefined"||catId == null || catId == "" || catId == "00000000-0000-0000-0000-000000000000" || catId == "00000000000000000000000000000000") return;
        var catName = $('#categories  option:selected').text();
        var exists = false;
        $('#ul_selectedCategories li').each(function(){
            if ($(this).children('.selectedCategories').val() == catId) {
                exists = true;
            }

        })

        if (exists) alert('This category has already been added!')
        else {
            $('#ul_selectedCategories').append(
                '<li>'+
        '<input type="hidden" class="selectedCategories"  name="selectedCategories" value="'+catId+'" />'
        +'<div>'+catName+'</div>'
        +'<input type="button" class="deleteCategoryBtn" value="Delete" />'+
    '</li>');

        }

    })

    $(document).on("click", "#ul_selectedCategories .deleteCategoryBtn", function () {
        $(this).parent('li').remove();
    })

    $(document).on("click", ".editBox .button.close", function () {
        $(this).parents('.editBox').html("");
    })

    

});

